/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amuthu.expression.function.math;

import org.amuthu.DataStore;
import org.amuthu.expression.Expression;
import org.amuthu.expression.exception.InvalidArgumentException;
import org.amuthu.expression.function.FunctionEvaluator;
import org.amuthu.parser.ExpressionVisitor;

/**
 *
 * @author prabhu
 */
public class LogarithmFunction implements FunctionEvaluator
{
   public LogarithmFunction()
   {
   }

   @Override
   public double computeIndicator(DataStore dataStore,Expression[] arguments, ExpressionVisitor visitor) throws InvalidArgumentException
   {
      if (arguments.length == 0)
      {
         throw new InvalidArgumentException("Log function zero args");
      }

      double number = visitor.evaluate(arguments[0]);

      return (number > 0) ? Math.log(number) : 0.0D;

   }

   public int computeDayDependency(DataStore dataStore, Expression[] arguments, ExpressionVisitor visitor) throws InvalidArgumentException
   {
      return 0;
   }

}
